package edu.hawaii.halealohacli.command;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.wattdepot.client.WattDepotClient;

/**
 * A Junit test for Monitor Power class.
 * @author mitchell kupfer
 *
 */
public class TestMonitorPower {
  MonitorPower testRT;
  String error;
  
  /**
   * Create a Monitor Power to test.
   */
  public TestMonitorPower() {
    testRT = new MonitorPower();
  }

  
  /**
   * Test initializeCommand method for correct argument handling.
   */
  @Test
  public void testInitializeCommand() {
    // URL is blank to avoid accessing server unnecessarily
    String url = "http://";
    String[] args = new String[3];
    error = "testInitializeCommand failed: Expected true";
    assertFalse(error, testRT.initializeCommand(new WattDepotClient(url), args));
    // Initialization should fail without enough arguments
    args = new String[0];
    error = "testInitializeCommand failed: Expected false";
    assertFalse(error, testRT.initializeCommand(new WattDepotClient(url), args));
    // Initialization should fail with too many arguments
    args = new String[4];
    error = "testInitializeCommand failed: Expected false";
    assertFalse(error, testRT.initializeCommand(new WattDepotClient(url), args));
  }
  
  /**
   * Test getName method for correct output.
   */
  @Test
  public void testGetName() {
    String url = "http://server.wattdepot.org:8190/wattdepot/";
    String[] args = new String[3];
    testRT.initializeCommand(new WattDepotClient(url), args);
    error = "testGetName failed: Message does not match expected values";
    assertTrue(error, testRT.getName().equals("monitor-power"));
  }
  
  
  
}
